package com.ldzy.webase.service.impl;

import com.ldzy.webase.dao.SlideshowMapper;
import com.ldzy.webase.entity.Slideshow;
import com.ldzy.webase.exception.ExceptionResponse;
import com.ldzy.webase.exception.ExceptionResponseCode;
import com.ldzy.webase.service.SlideshowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：Lq
 * @version ：1.0
 * @date ：2022/10/25 21:20
 * @description ：t_slideshow-轮播图表-业务层
 */
@Service
public class SlideshowServiceImpl implements SlideshowService {
    @Autowired
    SlideshowMapper slideshowMapper;

    /**
     * @author ：Lq
     * @date ：2022/10/25 21:56
     * @description ：获取轮播图列表，需要type参数 [0为首页轮播图，1未暂未定]
     */
    @Override
    public List<Slideshow> getSlideshowAllByType(String type) {
        List<Slideshow> slideshowAllByType = slideshowMapper.getSlideshowAllByType(type);

        if (slideshowAllByType.size() == 0) {
            throw ExceptionResponse.build(ExceptionResponseCode.ERROR_NOT_TOKEN);// (401, "服务器开小差了")
        }

        return slideshowAllByType;
    }
}
